home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / LargeTextPopup.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  2.1 KB  |  91 lines

  1.  
  2. -- This can be set directly:
  3. LargeTextColor = Color(1,1,1,0)
  4.  
  5. -- DON'T Set these directly:
  6. --TextFadeInDur = 1
  7. --TextWaitDur = 2.5
  8. --TextFadeOutDur = 1
  9. --TotalTextDur = TextFadeInDur + TextWaitDur + TextFadeOutDur
  10.  
  11. function SetTextPopupTiming( inTime, waitTime, outTime )
  12.     TextFadeInDur    = inTime;
  13.     TextWaitDur        = waitTime;
  14.     TextFadeOutDur    = outTime;
  15.     TotalTextDur = TextFadeInDur + TextWaitDur + TextFadeOutDur;
  16. end
  17.  
  18. function ResetTextPopupTiming()
  19.  
  20.     SetTextPopupTiming( 1, 2.5, 1 )
  21. end
  22.  
  23. ResetTextPopupTiming()        -- Set defaults
  24.  
  25.  
  26. function KillTextPopup()
  27.     if( not( TutorialText == nil ) and TutorialText.IsValid() ) then
  28.         TutorialText.Destroy();
  29.     end
  30. end
  31.  
  32. function LargeTextPopup( text )
  33.     if( TutorialText == nil or not(TutorialText.IsValid()) ) then
  34.         G.Create( "MenuData/TutorialTextCog.xml" );
  35.     end
  36.     
  37.     TutorialText.SetGuiPosition( "TutorialTextBox", Vector3(0,0,0) );
  38.     TutorialText.SetGuiText( "TutorialTextBox", text, 0 );
  39.     
  40.     LargeTextColor[3] = 0;
  41.     TutorialText.SetColor( "TutorialTextBox", LargeTextColor );
  42.     
  43.     TextFadeTime = TotalTextDur
  44. end
  45.  
  46. function ColorTextPopup( text, color )
  47.  
  48.     LargeTextColor = color
  49.     LargeTextPopup( text )
  50. end
  51.  
  52.  
  53. -- Popup icons too?
  54. function InvaderTextPopup( invaderName )
  55.     ResetTextPopupTiming()
  56.     ColorTextPopup( "New Invader: " .. invaderName .. "!", Color(0,0.85,0,1) )
  57. end
  58.  
  59. function TrapTextPopup( trapName )
  60.     ResetTextPopupTiming()
  61.     ColorTextPopup( "New Trap: " .. trapName .. "!", Color(0.25,0.25,1,1) )
  62. end
  63.  
  64.  
  65.  
  66. function TextFadeFunc()
  67.     -- Fade text over time
  68.     if( not( TutorialText == nil ) and TutorialText.IsValid() ) then
  69.         TextFadeTime = TextFadeTime - GameTimeDiff;
  70.  
  71.         -- First Fade in:
  72.         if( TextFadeTime > TextWaitDur + TextFadeOutDur ) then
  73.             LargeTextColor[3] = (TotalTextDur - TextFadeTime) / TextFadeInDur;
  74.         else 
  75.             if( TextFadeTime > TextFadeOutDur ) then
  76.                 LargeTextColor[3] = 1;
  77.             else
  78.                 LargeTextColor[3] = TextFadeTime / TextFadeOutDur;
  79.             end
  80.         end
  81.  
  82.         TutorialText.SetColor( "TutorialTextBox", LargeTextColor );
  83.  
  84.         if( TextFadeTime < 0 ) then
  85.             KillTextPopup()
  86.         end
  87.     end
  88. end
  89.  
  90. -- Always update Function:
  91. GMain[ "TextFadeFunc" ] = TextFadeFunc;